<template>
  <div class="page-container">
    <button class="back-button" @click="goToHome">
      <span class="icon-arrow-left"></span>
      返回首页
    </button>
    
    <div class="header-section">
      <h1>企事业单位客户管理</h1>
      <p>处理企业和事业单位客户事务，提供专属服务与合作管理</p>
    </div>
    
    <div class="tabs-container">
      <div class="tab active" data-tab="enterprise">企业客户</div>
      <div class="tab" data-tab="institution">事业单位</div>
    </div>
    
    <div class="action-bar">
      <div class="search-filter">
        <input 
          type="text" 
          placeholder="搜索单位名称/联系人..." 
          class="search-input"
        >
        <select class="filter-select">
          <option value="">全部规模</option>
          <option value="large">大型</option>
          <option value="medium">中型</option>
          <option value="small">小型</option>
        </select>
      </div>
      <button class="primary-btn">添加客户单位</button>
    </div>
    
    <div class="card">
      <div class="contract-alerts">
        <div class="alert-item">
          <span class="alert-icon">⚠️</span>
          <span class="alert-text">有 3 家单位的合同将在30天内到期</span>
          <button class="alert-btn">处理</button>
        </div>
      </div>
      
      <table class="data-table">
        <thead>
          <tr>
            <th>单位名称</th>
            <th>单位类型</th>
            <th>规模</th>
            <th>联系人</th>
            <th>联系方式</th>
            <th>合同到期日</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>恒通科技有限公司</td>
            <td>企业</td>
            <td>中型</td>
            <td>刘经理</td>
            <td>138****5678</td>
            <td class="warning">2023-11-25</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-contact">联系记录</button>
              <button class="btn-contract">合同管理</button>
            </td>
          </tr>
          <tr>
            <td>市第一人民医院</td>
            <td>事业单位</td>
            <td>大型</td>
            <td>陈主任</td>
            <td>139****1234</td>
            <td>2024-05-10</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-contact">联系记录</button>
              <button class="btn-contract">合同管理</button>
            </td>
          </tr>
          <tr>
            <td>宏图建筑集团</td>
            <td>企业</td>
            <td>大型</td>
            <td>杨总</td>
            <td>137****8901</td>
            <td class="danger">2023-10-30</td>
            <td class="action-buttons">
              <button class="btn-view">详情</button>
              <button class="btn-contact">联系记录</button>
              <button class="btn-contract">合同管理</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <div class="pagination">
      <button class="page-btn">上一页</button>
      <button class="page-btn active">1</button>
      <button class="page-btn">2</button>
      <button class="page-btn">3</button>
      <button class="page-btn">...</button>
      <button class="page-btn">8</button>
      <button class="page-btn">下一页</button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'EnterpriseCustomer',
  methods: {
    goToHome() {
      this.$router.push('/home');
    }
  },
  mounted() {
    // 为标签页添加点击事件
    const tabs = document.querySelectorAll('.tab');
    tabs.forEach(tab => {
      tab.addEventListener('click', () => {
        // 移除所有标签的active类
        tabs.forEach(t => t.classList.remove('active'));
        // 给当前点击的标签添加active类
        tab.classList.add('active');
        // 这里可以添加切换内容的逻辑
      });
    });
  }
}
</script>

<style scoped>
.page-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.header-section {
  margin: 20px 0 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
}

.header-section h1 {
  color: #2c3e50;
  margin-bottom: 10px;
  font-size: 24px;
}

.header-section p {
  color: #7f8c8d;
  font-size: 14px;
  margin: 0;
}

.tabs-container {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 16px;
  color: #7f8c8d;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
}

.tab.active {
  color: #3498db;
  border-bottom-color: #3498db;
  font-weight: 500;
}

.tab:hover:not(.active) {
  color: #34495e;
  border-bottom-color: #ddd;
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.search-filter {
  display: flex;
  gap: 10px;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 250px;
  font-size: 14px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
}

.primary-btn {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.primary-btn:hover {
  background-color: #2980b9;
}

.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.contract-alerts {
  padding: 12px 15px;
  background-color: #fff3cd;
  border-bottom: 1px solid #ffeeba;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-icon {
  font-size: 16px;
}

.alert-text {
  flex: 1;
  color: #856404;
  font-size: 14px;
}

.alert-btn {
  background-color: #ffc107;
  color: #856404;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.2s;
}

.alert-btn:hover {
  background-color: #e0a800;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}

.data-table th {
  background-color: #f9f9f9;
  font-weight: 600;
  color: #34495e;
}

.data-table tbody tr:hover {
  background-color: #f9f9f9;
}

.warning {
  color: #e67e22;
  font-weight: 500;
}

.danger {
  color: #e74c3c;
  font-weight: 500;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-view, .btn-contact, .btn-contract {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-view {
  background-color: #3498db;
  color: white;
}

.btn-contact {
  background-color: #2ecc71;
  color: white;
}

.btn-contract {
  background-color: #9b59b6;
  color: white;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 20px 0;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background-color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.page-btn.active {
  background-color: #3498db;
  color: white;
  border-color: #3498db;
}

.page-btn:hover:not(.active) {
  border-color: #3498db;
  color: #3498db;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  margin-right: 20px;
  font-weight: 500;
}

.back-button:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

.icon-arrow-left::before {
  content: '←';
}
</style>